#ifndef SM4_H
#define SM4_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

// SM4常量定义
#define SM4_BLOCK_SIZE 16
#define SM4_KEY_SIZE 16
#define SM4_ROUNDS 32

// SM4函数声明
void sm4_encrypt(const uint8_t key[SM4_KEY_SIZE], 
                 const uint8_t plaintext[SM4_BLOCK_SIZE], 
                 uint8_t ciphertext[SM4_BLOCK_SIZE]);

void sm4_decrypt(const uint8_t key[SM4_KEY_SIZE], 
                 const uint8_t ciphertext[SM4_BLOCK_SIZE], 
                 uint8_t plaintext[SM4_BLOCK_SIZE]);

void sm4_ecb_encrypt(const uint8_t key[SM4_KEY_SIZE], 
                     const uint8_t *input, 
                     uint8_t *output, 
                     size_t length);

void sm4_ecb_decrypt(const uint8_t key[SM4_KEY_SIZE], 
                     const uint8_t *input, 
                     uint8_t *output, 
                     size_t length);

void sm4_generate_key(uint8_t key[SM4_KEY_SIZE]);
int sm4_self_test(void);
void sm4_print_hex(const char *label, const uint8_t *data, size_t len);

#endif
